export const drawArc = (ctx, x, y, r, sAngle, eAngle, bgColor) => {
	ctx.save()
	ctx.beginPath()
	ctx.arc(x, y, r, sAngle, eAngle)
	ctx.fillStyle = bgColor
	ctx.fill()
	ctx.restore()
}


// H 是12小时制还24小时制
// r 是围绕旋转的大圆半径
export const getPoint = (time,startX, startY, r, H = 12) => {
	const wakeUp = time.split(':')
	const angle = (Number(wakeUp[0]) * 60 + Number(wakeUp[1])) * (360 / (H * 60))
	const endX = startX + r * Math.sin(angle / 180 * Math.PI)
	const endY = startY + (r - r * Math.cos(angle / 180 * Math.PI))
	return {
		x: endX,
		y: endY,
		rad: (angle / 180 + 1.5) * Math.PI
	}
}

export const drawPoint = (ctx,x,y,r,bgColor,bgImage) => {
	ctx.save()
	ctx.beginPath()
	// ctx.arc(x - 4, y + 3, r, 0, 2 * Math.PI)
	ctx.arc(x, y, r, 0, 2 * Math.PI)
	ctx.fillStyle = bgColor
	ctx.clip()
	if (bgImage) {
		// ctx.drawImage(bgImage,x - r - 4,y - r + 3,2 * r,2 * r)
		ctx.drawImage(bgImage,x - r,y - r,2 * r,2 * r)
	}
	ctx.fill()
	ctx.restore()
}
